<?php
require_once "./db_config.php";
if(isset($_POST['dept'])){
  $deptId=$_POST['dept'];
  $sql="SELECT
       	`姓名`,
       	`聘任职称` ,
       	`科室`,
         `性别`,`手机号码`,`ryxz`,`工号`,`档案编号`
       FROM
       	personalfiles_temp
       WHERE
       	 personalfiles_temp.office_id='$deptId'";
       $result=mysqli_query($conn,$sql);
       if(mysqli_num_rows($result) > 0){
         while($row = mysqli_fetch_assoc($result)) {
           $arr[]=$row;
         }
         echo json_encode($arr,JSON_UNESCAPED_UNICODE);
       }else{
         echo "ERROR!";
       }
}
$sql="SELECT
	`姓名`,
	`聘任职称` ,
	`科室`,
  `性别`,`手机号码`,`ryxz`,`工号`,`档案编号`
FROM
	personalfiles_temp,
	prs_dept
WHERE
	prs_dept.id = personalfiles_temp.office_id
	order BY `科室`";
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result) > 0){
  while($row = mysqli_fetch_assoc($result)) {
    $arr[]=$row;
  }
  echo json_encode($arr,JSON_UNESCAPED_UNICODE);
}else{
  echo "ERROR!";
}
mysqli_close($conn);
